﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using CUWo.Common.Entities.WoInterface;
using CUWo.Common.Entities.WoInterface.HttpArgument;

/**
 * 创建时间：2014/11/3 15:19:06
 * 作者：yong.blackcore
 * Email：itblackhole@outlook.com
 * QQ：50404503
 */
namespace CUWo.Common.WoInterfaceCommunication
{
    public class CommunicationBase
    {
        #region ******************************请求协议的方法名称******************************
        /// <summary>
        /// 请求地址
        /// <para>http://103.224.234.172/online/services/</para>
        /// <para>http://w2ol.wo.cn/online/services/</para>
        /// <para>http://w2ol.wo.cn/online/services/[功能ID]?channel=[渠道号]&amp;param=[请求内容]</para>
        /// </summary>
        public string ServiceAddress
        {
            get
            {
                //return "http://103.224.234.172/online/services/";
                return "http://w2ol.wo.cn/online/services/";
            }
        }

        /// <summary>
        /// 请求参数的Key
        /// <para>http://w2ol.wo.cn/online/services/[功能ID]?channel=[渠道号]&amp;param={"mblNum":"15600000000"}</para>
        /// </summary>
        public string ServiceAddressRequestQueryKey { get { return "param"; } }

        /// <summary>
        /// http://w2ol.wo.cn/online/services/[功能ID]?channel=[渠道号]&param=[请求内容]
        /// </summary>
        public string ServiceAddressRequestQueryChannelKey { get { return "channel"; } }

        public string CHANNEL_ID { get { return "8d3955e38c"; } }

        public string CHANNEL_PASSWORD { get { return "C343E0C030F43F433109B0FB73FF8237"; } }


        /// <summary>
        /// 手机号码注册
        /// <para>ol001</para>
        /// </summary>
        protected string Method_MobileRegister { get { return "ol001"; } }

        /// <summary>
        /// 重置密码
        /// </summary>
        protected string Method_PasswordReset { get { return "ol002"; } }

        /// <summary>
        /// 修改密码
        /// </summary>
        protected string Method_PasswordUpdate { get { return "ol003"; } }

        /// <summary>
        /// 验证码发送
        /// </summary>
        protected string Method_CaptchaSend { get { return "ol004"; } }

        /// <summary>
        /// 验证码验证
        /// </summary>
        protected string Method_CaptchaConfirm { get { return "ol005"; } }

        /// <summary>
        /// 号码归属地查询
        /// </summary>
        protected string Method_MobileNumberLocator { get { return "ol006"; } }

        /// <summary>
        /// 获取活动信息
        /// </summary>
        protected string Method_GetActiveInfo { get { return "ol007"; } }

        /// <summary>
        /// 获取广告信息
        /// </summary>
        protected string Method_GetAdInfo { get { return "ol008"; } }

        /// <summary>
        /// 获取新闻频道
        /// </summary>
        protected string Method_GetNewsChannel { get { return "ol009"; } }

        /// <summary>
        /// 获取当前流量使用状况
        /// </summary>
        protected string Method_GetTrackCurrent { get { return "ol010"; } }

        /// <summary>
        /// 获取历史流量使用状况
        /// </summary>
        protected string Method_GetTrackHistory { get { return "ol011"; } }

        /// <summary>
        /// 签到
        /// </summary>
        protected string Method_CheckIn { get { return "ol012"; } }

        /// <summary>
        /// 获取首页流量公告
        /// </summary>
        protected string Method_GetTrackHome { get { return "ol013"; } }

        /// <summary>
        /// 获取基地业务信息
        /// </summary>
        protected string Method_GetBaseInfo { get { return "ol014"; } }

        /// <summary>
        /// 获取新闻
        /// </summary>
        protected string Method_GetNewsContent { get { return "ol015"; } }

        /// <summary>
        /// 用户反馈
        /// </summary>
        protected string Method_SubmitFeedback { get { return "ol016"; } }

        /// <summary>
        /// 获取闪屏信息
        /// </summary>
        protected string Method_GetFlashInfo { get { return "ol017"; } }

        /// <summary>
        /// 获取新闻频道是否更新
        /// </summary>
        protected string Method_GetChannelCheck { get { return "ol018"; } }


        /// <summary>
        /// 获取流量包推荐信息
        /// </summary>
        protected string Method_GetTrackGroup { get { return "ol019"; } }

        /// <summary>
        /// 获取最新版本
        /// </summary>
        protected string Method_GetNewestLast { get { return "ol020"; } }


        /// <summary>
        /// 获取是否开通沃邮箱
        /// <para>第三方</para>
        /// </summary>
        protected string Method_GetEmailIsOpen { get { return "ol021"; } }

        /// <summary>
        /// 手机号码登录
        /// </summary>
        protected string Method_MobileSign { get { return "ol022"; } }

        /// <summary>
        /// Log
        /// </summary>
        protected string Method_MobileLog { get { return "ol023"; } }

        /// <summary>
        /// 获取沃邮箱未读邮件数
        /// <para>第三方</para>
        /// </summary>
        protected string Method_GetEmailUnreader { get { return "ol024"; } }

        /// <summary>
        /// 获取沃邮箱注册URL
        /// <para>第三方</para>
        /// </summary>
        protected string Method_GetEmailRegisterUrl { get { return "ol025"; } }

        /// <summary>
        /// 获取沃邮箱登录URL
        /// <para>第三方</para>
        /// </summary>
        protected string Method_GetEmailSignUrl { get { return "ol026"; } }

        /// <summary>
        /// 获取当前流量使用状况(网页版)
        /// </summary>
        protected string Method_GetTrackCurrentByWebSite { get { return "ol027"; } }

        /// <summary>
        /// 获取流量包推荐信息(网页版)
        /// </summary>
        protected string Method_GetTrackGroupByWebSite { get { return "ol028"; } }

        /// <summary>
        /// net取号
        /// </summary>
        protected string Method_NetGetNumber { get { return "ol029"; } }

        /// <summary>
        /// net取号(unikey获得)
        /// </summary>
        protected string Method_NetGetNumberByUnikey { get { return "ol030"; } }
        #endregion ******************************请求协议的方法名称******************************

        protected ArgsBase RequestArgument { get; set; }

        public CommunicationBase()
        {
            RequestArgument = new ArgsBase();
            RequestArgument.AppVer = AppHelper.GetAssemblyVersion.ToString();
            RequestArgument.Debug = Convert.ToInt32(WoInterfaceDebugFlag.Open).ToString();
            //            RequestArgument.Debug = Convert.ToInt32(WoInterfaceDebugFlag.Close).ToString();
            RequestArgument.IEMI = DeviceInfoHelper.GetIMEI;
            RequestArgument.MobileFrim = DeviceInfoHelper.GetDeviceManufacturer;
            RequestArgument.MobileType = DeviceInfoHelper.GetDeviceName;
            RequestArgument.OS = DeviceInfoHelper.GetDeviceOS;
            RequestArgument.OSVersion = DeviceInfoHelper.GetDeviceOSVersion;
        }

        public ArgsBase InitHttpCommBass<T>() where T : new()
        {
            ArgsBase result = new ArgsBase();
            T item = new T();
            //

            if (item is ArgsActiveInfo)
                result = item as ArgsActiveInfo;
            else if (item is ArgsAdInfo)
                result = item as ArgsAdInfo;
            else if (item is ArgsBaseInfo)
                result = item as ArgsBaseInfo;
            else if (item is ArgsCaptchaConfirm)
                result = item as ArgsCaptchaConfirm;
            else if (item is ArgsCaptchaSend)
                result = item as ArgsCaptchaSend;
            else if (item is ArgsCheckIn)
                result = item as ArgsCheckIn;
            else if (item is ArgsEmailIsOpen)
                result = item as ArgsEmailIsOpen;
            else if (item is ArgsEmailRegisterUrl)
                result = item as ArgsEmailRegisterUrl;
            else if (item is ArgsEmailSignUrl)
                result = item as ArgsEmailSignUrl;
            else if (item is ArgsEmailUnreader)
                result = item as ArgsEmailUnreader;
            //10
            else if (item is ArgsFlashInfo)
                result = item as ArgsFlashInfo;
            else if (item is ArgsMobileLog)
                result = item as ArgsMobileLog;
            else if (item is ArgsMobileNumberLocator)
                result = item as ArgsMobileNumberLocator;
            else if (item is ArgsMobileRegister)
                result = item as ArgsMobileRegister;
            else if (item is ArgsMobileSign)
                result = item as ArgsMobileSign;
            else if (item is ArgsNetGetNumber)
                result = item as ArgsNetGetNumber;
            else if (item is ArgsNetGetNumberByUnikey)
                result = item as ArgsNetGetNumberByUnikey;
            else if (item is ArgsNewestVersionLast)
                result = item as ArgsNewestVersionLast;
            else if (item is ArgsNewsChannel)
                result = item as ArgsNewsChannel;
            else if (item is ArgsNewsChannelCheck)
                result = item as ArgsNewsChannelCheck;
            //20
            else if (item is ArgsNewsContent)
                result = item as ArgsNewsContent;
            else if (item is ArgsPasswordReset)
                result = item as ArgsPasswordReset;
            else if (item is ArgsPasswordUpdate)
                result = item as ArgsPasswordUpdate;
            else if (item is ArgsSubmitFeedback)
                result = item as ArgsSubmitFeedback;
            else if (item is ArgsTrackCurrent)
                result = item as ArgsTrackCurrent;
            else if (item is ArgsTrackCurrentByWebSite)
                result = item as ArgsTrackCurrentByWebSite;
            else if (item is ArgsTrackGroup)
                result = item as ArgsTrackGroup;
            else if (item is ArgsTrackGroupByWebSite)
                result = item as ArgsTrackGroupByWebSite;
            else if (item is ArgsTrackHistory)
                result = item as ArgsTrackHistory;
            else if (item is ArgsTrackHome)
                result = item as ArgsTrackHome;

            //
            result.AppVer = this.RequestArgument.AppVer;
            result.Debug = this.RequestArgument.Debug;
            result.IEMI = this.RequestArgument.IEMI;
            result.MobileFrim = this.RequestArgument.MobileFrim;
            result.MobileType = this.RequestArgument.MobileType;
            result.OS = this.RequestArgument.OS;
            result.OSVersion = this.RequestArgument.OSVersion;

            return result;
        }
    }
}
